//
//  TSNormalTableViewCell.swift
//  TSProfitProject
//
//  Created by TMS on 2019/11/4.
//  Copyright © 2019 TMS. All rights reserved.
//

import UIKit

struct TSNormalCellModel {
    var title : String
    var value : String
    var textColor : String
    var font : UIFont
    var imgName : String
}

class TSNormalTableViewCell: UITableViewCell {
    
    var containerView : UIView!
    var titleLabel : UILabel!
    var moreIcon : UIImageView!
    var line : UIView!
    var cellModel : TSNormalCellModel?

    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        self.selectionStyle = .none
        configViews()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    func setupCell(model:TSNormalCellModel, last:Bool) {
        cellModel = model
        
        titleLabel.text = model.title
        titleLabel.textColor = UIColor.hexadecimalColor(hexadecimal: cellModel!.textColor)
        titleLabel.font = cellModel?.font
        line.isHidden = last
    }
    
    func configViews() {
        
        containerView = UIView.init()
        containerView.backgroundColor = WHITE_COLOR
        self.contentView.addSubview(containerView)
        containerView.snp.makeConstraints { (make) in
            make.left.right.top.equalToSuperview()
            make.height.equalTo(50)
        }
        
        titleLabel = UILabel.init()
//        titleLabel.font = UIFont.systemFont(ofSize: 14)
//        titleLabel.textColor = UIColor.hexadecimalColor(hexadecimal: "#702FC9")
        containerView.addSubview(titleLabel)
        titleLabel.snp.makeConstraints { (make) in
            make.centerY.equalToSuperview()
            make.left.equalTo(12)
        }
        
        moreIcon = UIImageView.init(image: UIImage(named: "general_more"))
        containerView.addSubview(moreIcon)
        moreIcon.snp.makeConstraints { (make) in
            make.centerY.equalToSuperview()
            make.right.equalTo(-12)
        }
        
        line = UIView.init()
        line.backgroundColor = BASE_LINE_COLOR
        containerView.addSubview(line)
        line.snp.makeConstraints { (make) in
            make.left.right.bottom.equalToSuperview()
            make.height.equalTo(1)
        }
    }
}
